//
//  LeftSortsViewController.m
//  autostainer
//
//  Created by lurenjia on 2017/5/16.
//  Copyright © 2017年 walker. All rights reserved.
//

#import "LeftSortsViewController.h"
#import "ViewController.h"

@interface LeftSortsViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) NSArray *titleArray;
@property (nonatomic,strong) UITableView *tableView;
@end

@implementation LeftSortsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   self.titleArray = @[@"设备介绍", @"团队介绍", @"蓝牙设置", @"关于"];
    //初始化背景图片
//    UIImageView *bgImgView = [[UIImageView alloc] initWithFrame:self.view.bounds];
//    bgImgView.image = [UIImage imageNamed:@"image.png"];
//    [self.view addSubview:bgImgView];  #021A36
    self.view.backgroundColor = [UIColor colorWithRed:2/255.0 green:26/255.0 blue:54/255.0 alpha:1.0];
    //初始化表视图
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"leftTableCell"];
    [self.view addSubview:self.tableView];
}

#pragma mark - tableView dataSource && delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titleArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"leftTableCell" forIndexPath:indexPath];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.font = [UIFont systemFontOfSize:20.0f];
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.textColor = [UIColor whiteColor];
    
    cell.textLabel.text = self.titleArray[indexPath.row];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 180;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 180)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 2) {
        ViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"ViewController"];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
@end
